<template>
  <div>
    <van-sticky>
      <van-nav-bar
        title="确认订单"
        left-arrow
        @click-left="onClickLeft(id)"
        fixed
      />
    </van-sticky>
    <van-address-list
      v-model="chosenAddressId"
      :list="list"
      default-tag-text="默认"
      @add="onAdd(id)"
      @edit="onEdit(id)"
    />
  </div>
</template>

<script>
export default {
  name: "Edit",

  data() {
    return {
      id: this.$route.params.id,
      chosenAddressId: 1,
      list: [],
      name:"",
      tel:"",
      address:""
    };
  },

  mounted() {
    this.getAddressList();
  },

  methods: {
    onClickLeft(id) {
      this.$router.push("/buy/" + id);
    },
    getAddressList(){
      this.$axios.get('/address').then(res => {
        this.list = res.data
      })
    },
    onAdd(id){
      this.$router.push('/addressEdit/' + id)
    },
    onEdit(id) {
      this.$router.push('/addressEdit/' + id)
    },
  },
};
</script>

<style scoped>
.van-radio-group {
  margin-top: 40px;
}
</style>